#ifndef _GTTHREAD_H_
#define _GTTHREAD_H_

#include "gtdescr.h"

/* function must be called from the main thread before any other GTThreads
 * functions are called. It allows the caller to specify the scheduling period
 * (quantum in micro second), and may also perform any other initialization you
 * deem necessary.
 * */
void gtthread_init(long period); //

/* function does not have an attr parameter. All your threads should behave as
 * if they have default PThread attributes (i.e. as if you specified NULL for
 * attr). In addition to not needing to implement attributes, you may have
 * noticed that there is no gtthread_detach(thread) function. You are not
 * required to implement detached threads; all threads should be joinable
 * */
extern int gtthread_create(gtthread_t *thread,
                            void *(*start_routine)(void *),
                            void *arg); //

extern int gtthread_join(gtthread_t thread, void **status); //

extern void gtthread_exit(void *retval); //

/* function does not have to return an error code; it may return void.
 * */
extern void gtthread_yield(void); //

extern int gtthread_equal(gtthread_t t1, gtthread_t t2); //

/* function does not have to implement deferred cancellation; all canceled
 * threads should be killed immediately.
 * */
extern int gtthread_cancel(gtthread_t thread);

extern gtthread_t gtthread_self(void); //

/* function does not have an attr parameter. All your mutexes should behave as
 * if they have default mutex attributes (i.e. as if you specified NULL for
 * attr). You are not required to implement gtthread_mutex_destroy(mutex),
 * gtthread_mutex_trylock(mutex), or a static initializer
 * (e.g. GTTHREAD_MUTEX_INITIALIZER).
 * */
extern int gtthread_mutex_init(gtthread_mutex_t *mutex);

extern int gtthread_mutex_lock(gtthread_mutex_t *mutex);

extern int gtthread_mutex_unlock(gtthread_mutex_t *mutex);

#endif /* _GTTHREAD_H_ */
